﻿using System;

namespace MST_02_03_delete_middle_node_lcci
{

    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode (int x) { val = x; }
    }
    class Program
    {
        static void Main (string[] args)
        {
            ListNode a = new ListNode (1);
            a.next = new ListNode (2);
            ListNode c = new ListNode (3);
            a.next.next = c;
            a.next.next.next = new ListNode (4);
            a.next.next.next.next = new ListNode (5);
            a.next.next.next.next.next = new ListNode (6);

            DeleteNode (c);

            while(a != null)
            {
                Console.Write (a.val + "->");
                a = a.next;
            }
            
        }
        public static void DeleteNode (ListNode node)
        {
            node.val = node.next.val;
            node.next = node.next.next;
        }
    }
}
